package com.glq1218.exception;

import com.glq1218.enums.ResultEnum;

/**
 * 自定义异常类
 */
public class CustomException extends RuntimeException {

    private final Integer code;
    private final String message;

    public CustomException(ResultEnum resultEnum) {
        super(resultEnum.getMessage());
        this.code = resultEnum.getCode();
        this.message = resultEnum.getMessage();
    }

    //接收自定义msg的方式构造业务异常
    public CustomException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public CustomException(String message) {
        super(message);
        this.code = 500;
        this.message = message;
    }

    public Integer getCode() {
        return this.code;
    }
}
